<%-- 
    Document   : admin-user
    Created on : Apr 6, 2011, 9:25:23 PM
    Author     : Yongke
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <div id="user">
        <label>User</label>
        <table border="1">

            <tr>
                <td>UserName</td>
                <td>Name</td>
                <td>Email</td>
                <td>Password</td>
                <td>Role</td>
                <td>Room Max</td>
                <td>Change Room Max</td>
                <td>Become Moderator?</td>
                <td>Status Ban</td>
                <td>Ban/Unban</td>
            </tr>
        <%
String connectionURL = "jdbc:mysql://localhost/myrc";
Connection connection = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost/myrc?user=progin&password=progin");
ResultSet rst=null;
Statement stm=null;
stm=connection.createStatement();
rst=stm.executeQuery("select * from user where role = 0 ");
int i=1;
while (rst.next())
    {
%>
            <tr>
                <td><%=rst.getString(1)%></td>
                <td><%=rst.getString(2)%></td>
                <td><%=rst.getString(3)%></td>
                <td><%=rst.getString(4)%></td>
                <td><%=rst.getString(5)%></td>
                <td><%=rst.getString(7)%></td>
                <td>
                    <form action="admin.jsp">
                        <input type="hidden" value="<%=rst.getString(1)%>" name="roommaxX" />
                        <input type="text" value="" name="roommax"/>
                        <input type="submit" value="Tambah"/>
                    </form>
                </td>
                <td><a href="admin.jsp?namauser=<%=rst.getString(1)%>">Become Moderator?</a></td>
                <%
                if (rst.getInt(6) == 0)
                {
                %>
                <td>unban</td>
                <td><a href="admin.jsp?statusban1=<%=rst.getString(1)%>">Ban?</a></td>
                <%
                }
                else
                {
                %>
                <td>ban</td>
                <td><a href="admin.jsp?statusban2=<%=rst.getString(1)%>">Unban?</a></td>
                <%
                }
                %>
            </tr>
<%}
rst.close();
%>
        </table>
        </div>
	<div id="moderator">
                <label>User Moderator</label>
                <table border="1">

                <tr>
                    <td>UserName</td>
                    <td>Name</td>
                    <td>Email</td>
                    <td>Password</td>
                    <td>Role</td>
                    <td>Room Max</td>
                    <td>Change Room Max</td>
                    <td>Become User?</td>
                    <td>Status Ban</td>
                    <td>Ban/Unban</td>
                </tr>
                <%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost/myrc?user=progin&password=progin");
ResultSet rstmod=null;
rstmod=stm.executeQuery("select * from user where role = 1 ");
while (rstmod.next())
        {
%>
                <tr>
                    <td><%=rstmod.getString(1)%></td>
                    <td><%=rstmod.getString(2)%></td>
                    <td><%=rstmod.getString(3)%></td>
                    <td><%=rstmod.getString(4)%></td>
                    <td><%=rstmod.getString(5)%></td>
                    <td><%=rstmod.getString(7)%></td>
                    <td>
                        <form action="admin.jsp">
                            <input type="hidden" value="<%=rstmod.getString(1)%>" name="roommaxX" />
                            <input type="text" value="" name="roommax"/>
                            <input type="submit" value="Tambah"/>
                        </form>
                    </td>
                    <td><a href="admin.jsp?namamod=<%=rstmod.getString(1)%>">Become User?</a></td>
                <%
                if (rstmod.getInt(6) == 0)
                {
                %>
                <td>unban</td>
                <td><a href="admin.jsp?statusban1=<%=rstmod.getString(1)%>">Ban?</a></td>
                <%
                }
                else
                {
                %>
                <td>ban</td>
                <td><a href="admin.jsp?statusban2=<%=rstmod.getString(1)%>">Unban?</a></td>
                <%
                }
                %>
                </tr>
<%}
rstmod.close();
%>
                </table>
                </div>
                <div id="category">
                         <label>Kategori</label>
                <table border="1">

                <tr>
                    <td>Kode Kategori</td>
                    <td>Nama Kategori</td>
                    <td>Tambah Sub Kategori</td>
                    <td>Setting</td>
                    <td>Change Name</td>
                </tr>
                <%

Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost/myrc?user=progin&password=progin");
ResultSet rstkat=null;
rstkat=stm.executeQuery("select * from kategori ");
while (rstkat.next())
        {
%>
                <tr>
                    <td><%=rstkat.getString(1)%></td>
                    <td><%=rstkat.getString(2)%></td>
                    <td>
                        <form class="addsubkategori" action="admin.jsp">
                        <input type="hidden" name="addkategoriX" value="<%=rstkat.getString(1)%>" />
                        <input type="text" name="addsubkategori" value="" />
                        <input type="submit" value="Tambah" name="addbutton" />
                        </form>
                    </td>
                    <td><a href="admin.jsp?hapuskat=<%=rstkat.getString(1)%>">Hapus</a></td>
                    <td>
                        <form class="" action="admin.jsp">
                        <input type="hidden" name="idkat" value="<%=rstkat.getString(1)%>" />
                        <input type="text" name="changenamekat" value="" />
                        <input type="submit" value="Ubah" />
                        </form>
                    </td>
                </tr>
<%}
rstkat.close();
//stm.close();
//connection.close();
%>
                </table>
                </div>
                <div id="subcategory">
                <label>Sub Kategori</label>
                <table border="1">
                <tr>
                    <td>Kode Sub Kategori</td>
                    <td>Kode Kategori</td>
                    <td>Nama Sub Kategori</td>
                    <td>Setting</td>
                    <td>Change Naame</td>
<%

Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost/myrc?user=progin&password=progin");
ResultSet rstsub=null;
rstsub=stm.executeQuery("select * from subkategori ");
while (rstsub.next())
        {
%>
                <tr>
                    <td><%=rstsub.getString(1)%></td>
                    <td><%=rstsub.getString(2)%></td>
                    <td><%=rstsub.getString(3)%></td>
                    <td><a href="admin.jsp?hapussub=<%=rstsub.getString(1)%>">Hapus</a></td>
                    <td>
                        <form class="" action="admin.jsp">
                        <input type="hidden" name="idsub" value="<%=rstsub.getString(1)%>" />
                        <input type="text" name="changenamesub" value="" />
                        <input type="submit" value="Ubah" />
                        </form>
                    </td>
                </tr>
<%}
rstsub.close();
stm.close();
connection.close();
%>
                </table>
                </div>
                <div id="add">
                <form class="addkategori" action="admin.jsp">
                <table border="1">
                        <tbody>
                            <tr>
                                <td>Tambah Kategori</td>
                                <td><input type="text" name="addkategori" value="" /></td>
                            </tr>
                        </tbody>
                </table>
                <input type="submit" value="Tambah" name="addbutton" />
                </form>
                </div>

    </body>
</html>
